package ooday04.homework.homework_01;

public class PolymorphicDemo {
    public static void main(String[] args) {
        Animal[]animals=new Animal[3];
        animals[0]=new Dog("小黑",2,"黑色");
        animals[1]=new Chick("小鸡",1,"黄色");
        animals[2]=new Fish("小金",3,"金色");
        for (Animal animal:animals){
            System.out.println(animal.getName());
            animal.eat();
            animal.drink();
            if (animal instanceof Dog){
                Dog dog=(Dog)animal;
                dog.lookHome();
            }
            if (animal instanceof Chick){
                Chick chick=(Chick)animal;
                chick.layEggs();
            }
            if (animal instanceof Swim){
                Swim s=(Swim)animal;
                s.swim();
            }
        }

        System.out.println("---------------");
        Master master=new Master();
        master.feed(animals[0]);
        master.feed(animals[1]);
        master.feed(animals[2]);
    }
}
